package com.yxch.admin.service.impl.semester;

import com.yxch.admin.mapper.semester.SemesterMapper;
import com.yxch.admin.model.commen.PageResult;
import com.yxch.admin.model.semester.SemesterDTO;
import com.yxch.admin.service.semester.SemesterService;
import com.yxch.admin.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SemesterServiceImpl implements SemesterService {
    @Autowired
    private SemesterMapper semesterMapper;

    @Override
    public ResultAPI getAllSemesters(SemesterDTO semesterDTO) {
        Integer pageNum = semesterDTO.getPageNum();
        Integer pageSize = semesterDTO.getPageSize();
        Integer start = (pageNum - 1) * pageSize;
        semesterDTO.setStart(start);
        PageResult pageResult = semesterMapper.getAllSemesters(semesterDTO);
        return ResultAPI.success(pageResult);
    }

    @Override
    public ResultAPI deleteSemesters(List<Integer> ids) {
        semesterMapper.deleteSemesters(ids);
        return ResultAPI.success();
    }
}
